package com.lenovo.smarttraffic.util;

import android.text.TextUtils;

public class FormatUtils {

    //判断是否是合法用户名，长度大于6
    public static boolean isAccount(String text) {
        String regex = "[0-9a-zA-Z]*";
        return !TextUtils.isEmpty(text) && text.matches(regex) && text.length() >= 4;
    }

    //判断是否是合法密码，长度大于6
    public static boolean isPwd(String text) {
        String regex = "[0-9a-zA-Z]*";
        return !TextUtils.isEmpty(text) && text.matches(regex) && text.length() >= 6;
    }

    //判断是否是合法邮箱
    public static boolean isEmail(String text) {
        String regex = "[A-Za-z0-9]+([_.][A-Za-z0-9]+)*@([A-Za-z0-9\\-]+\\.)+[A-Za-z]{2,6}$";
        return !TextUtils.isEmpty(text) && text.matches(regex);
    }

    //判断是否是合法手机号
    public static boolean isPhone(String text) {
        String regExp = "^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(166)|(17[3,5,6,7,8])|(18[0-9])|(19[8,9]))\\d{8}$";
        return !TextUtils.isEmpty(text) && text.matches(regExp);
    }

}
